package handler

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"yzy6.26exam/api/request"
	"yzy6.26exam/golbal"
	"yzy6.26exam/internal/moble"
)

func VideoMyPush(context *gin.Context) {
	var video_my_push request.VideoMyPush
	if err := context.ShouldBind(&video_my_push); err != nil {
		context.JSON(http.StatusBadRequest, gin.H{
			"code":    204,
			"message": "解析失败",
			"data":    err.Error(),
		})
		return
	}
	var videos []moble.Video
	if err := golbal.DB.Where("user_id = ?", video_my_push.UserId).Order("created_at desc").Find(&videos).Error; err != nil {
		context.JSON(http.StatusOK, gin.H{
			"code":    203,
			"message": "查询失败",
			"data":    err,
		})
		return
	}
	context.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "查询成功",
		"data":    videos,
	})
}
